package com.example.controller.note;

import com.alibaba.fastjson.JSONObject;
import com.example.config.auth.SecurityUtil;
import com.example.ribbon.service.NoteTypeRibbonService;
import com.example.util.EnhancedGetUrlBuilder;
import com.example.util.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/notetype")
public class NoteTypeController {

    @Autowired
    NoteTypeRibbonService noteTypeRibbonService;

    @GetMapping("/add")
    public JSONObject addNoteType(@RequestParam("typeName")String typeName) {
        return noteTypeRibbonService.addNoteType(typeName);
    }

    @GetMapping("/getone")
    public JSONObject getNoteType(@RequestParam("typeId")String typeId,
                                  @RequestParam("nodeId")String nodeId) {
        return noteTypeRibbonService.getNoteType(nodeId, typeId);
    }

    @GetMapping("/getnotetype/list")
    public JSONObject getNoteTypeList() {
        String userId= SecurityUtil.getUserId();
        return noteTypeRibbonService.getNoteTypeListByUserId(userId);
    }

    @GetMapping("/getnotetype/userId")
    public JSONObject getNoteTypeByUserId(@RequestParam("userId")String userId) {
        return noteTypeRibbonService.getNoteTypeListByUserId(userId);
    }
}
